<?php 
	/**
	 * 每天删除30天以前的数据
	 */

	include_once dirname(dirname(__FILE__))."/include/common.inc.php";
	
	$beforeday = date('Y-m-d',time()-30*24*60*60);
	$global_site = "tools";
	//处理抓取的页面
	$compeitior = array('baihe','ganji','zhenai','yuanlai');
	foreach($compeitior as $key=>$value){
		$dir = ROOT_PATH .'\\'.$value.'\\pages\\'.$beforeday;
		if(is_dir($dir)){
			if(deldir($dir)){
				printlog("删除 $dir 数据成功！",'cleardata');
			}else{
				printlog("删除 $dir 数据失败，请手工处理！",'cleardata');
			}
		}else{
			printlog("$dir 不存在，无需处理！",'cleardata');
		}
	}
	//处理除赶集之外的log
	$filetime = date('Ymd',time()-30*24*60*60);
	$samelogname = array('baihe','zhenai','yuanlai');
	$filearray = array ('_crawl.txt','_extract_error.txt','_main.txt','_sendmail.txt','_warning.txt');
	foreach($samelogname as $key=>$value){
		$prefilename = ROOT_PATH .'\\'.$value.'\\'.'log\\'.$filetime;
		foreach($filearray  as $v=>$file){
			$filename = $prefilename.$file;
			echo $filename."<br />";
			if(is_file($filename)){
				unlink($filename);
			}
		}
	}
	//处理赶集的log
	$ganjiarray = array('_debug.txt','_mysql_error.txt','_sendmail.txt','_warning.txt');
	foreach($ganjiarray as $g=>$gf){
		$gfilename = ROOT_PATH .'\\ganji\\'.'log\\'.$filetime.$gf;
		echo $gfilename."<br />";
		if(is_file($gfilename)){
			unlink($gfilename);
		}
	}
	
?>